package com.example.demo.controller;

import com.example.demo.model.Bhmana;
import com.example.demo.service.IBhmanaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author Administrator 张少婷
 */

@Api(tags = "补货信息")
@RestController
@RequestMapping("/swagger11")
public class BhmanaController {
    @Autowired
    private IBhmanaService bhmanaService;
    @CrossOrigin
    @ApiOperation(value="添加补货信息")
    @PostMapping("/insertBhmana")
    public int insertBhmana(@RequestBody Bhmana bhmana){
        System.out.println("进入添加补货信息接口" );
        return bhmanaService.insertBhmana(bhmana);
    }

    @PostMapping("/getAllBhmana")
    public List<Bhmana> getAllBhmana(@RequestBody Bhmana bhmana)
    {
        System.out.println("进入查询方法");
        List<Bhmana> listBhmana=bhmanaService.getAllBhmana(bhmana);
        return listBhmana;
    }
    @PostMapping("/editBhmana")
    public int EditBhmana(@RequestBody Bhmana bhmana){
        System.out.println("添加修改方法");
        return bhmanaService.updateBhmana(bhmana);
    }
    @GetMapping("/delBhmana")
    public int Delete(int lbid){
        System.out.println("进入删除方法");
        int returnValues=0;
        if(lbid!=0){
            Bhmana bhmana=new Bhmana();
            bhmana.setLbid(lbid);
            returnValues=bhmanaService.deleteBhmana(bhmana);
        }
        return returnValues;
    }

    @GetMapping("/getOneBhmana")
    public Bhmana getBhmana(int lbid){
        Bhmana bhmana=new Bhmana();
        System.out.println("进入单条查询方法");
        if(lbid!=0){
            Bhmana bhmana1=new Bhmana();
            bhmana1.setLbid(lbid);
            bhmana=bhmanaService.getBhmana(bhmana1);
            System.out.println("返回的数据集合为:"+bhmana.getLbid());
        }
        return bhmana;
    }
}
